const express = require('express');
const router = express.Router();
const attendance_handler = require('../router_handler/attendance');
const expressJoi = require('@escook/express-joi');
const {
	getCompanyAttendance_schema,
	getDepartmentAttendance_schema,
	getUserAttendance_schema,
	getUserAttendanceStat_schema,
	applyRest_schema,
	getRestLog_schema,
	getAuditRsetLog_schema,
	refuseRest_schema,
	agreeRest_schema,
	applyOvertime_schema,
	getOvertimeLog_schema,
	getAuditOvertimeLog_schema,
	refuseOvertime_schema,
	agreeOvertime_schema,
	updateInitial_schema,
	holidaysRest_schema,
} = require('../schema/attendance');

// 查询公司考勤记录
router.get('/getCompanyAttendance', attendance_handler.getCompanyAttendance);

// 查询部门考勤记录
router.get('/getDepartmentAttendance', attendance_handler.getDepartmentAttendance);

// 通过用户id查询个人考勤记录
router.get('/getUserAttendance', attendance_handler.getUserAttendance);

// 查询用户考勤统计
router.get('/getUserAttendanceStat', attendance_handler.getUserAttendanceStat);

// 申请调休
router.post('/applyRest', expressJoi(applyRest_schema), attendance_handler.applyRest);
// 查询自己的调休记录
router.get('/getRestLog', attendance_handler.getRestLog);
// 查询由自己审核的调休记录
router.get('/getAuditRsetLog', attendance_handler.getAuditRsetLog);
// 驳回调休申请
router.post('/refuseRest', expressJoi(refuseRest_schema), attendance_handler.refuseRest);
// 同意调休申请
router.post('/agreeRest', expressJoi(agreeRest_schema), attendance_handler.agreeRest);

// 申请加班
router.post('/applyOvertime', expressJoi(applyOvertime_schema), attendance_handler.applyOvertime);
// 查询自己的加班申请
router.get('/getOvertimeLog', attendance_handler.getOvertimeLog);
// 查询由自己审核的加班记录
router.get('/getAuditOvertimeLog', attendance_handler.getAuditOvertimeLog);
// 驳回加班申请
router.post('/refuseOvertime', expressJoi(refuseOvertime_schema), attendance_handler.refuseOvertime);
// 同意加班申请
router.post('/agreeOvertime', expressJoi(agreeOvertime_schema), attendance_handler.agreeOvertime);

// 考勤初始化
// 修改工作起始日，调休基数
router.post('/updateInitial', expressJoi(updateInitial_schema), attendance_handler.updateInitial);
// 节假日设置
router.post('/holidaysRest', expressJoi(holidaysRest_schema), attendance_handler.holidaysRest);
// 获取考勤初始化数据
router.get('/getInitial', attendance_handler.getInitial)

// 获取具备审核权限的用户
router.get('/getExamineUserList', attendance_handler.getExamineUserList)

module.exports = router;